package com.dgut.doctorservice.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.dgut.commonutils.Result;
import com.dgut.doctorservice.entity.AdministratorInfo;
import com.dgut.doctorservice.service.AdministratorInfoService;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author dgut
 * @since 2021-09-28
 */
@RestController
@RequestMapping("/doctorservice/administrator-info")
@CrossOrigin
public class AdministratorInfoController {

    @Autowired
    AdministratorInfoService administratorInfoService;

    @ApiOperation("管理员登录")
    @PostMapping("adminLogin")
    public Result adminLogin(@RequestParam String account,@RequestParam String password){
        QueryWrapper<AdministratorInfo> wrapper = new QueryWrapper<>();
        wrapper.eq("account",account);
        AdministratorInfo one = administratorInfoService.getOne(wrapper);
        if (one==null){
            return Result.succ().message("账户不存在！");
        }else{
            if (one.getPassword().equals(password)){
                return Result.succ();
            }else {
                return Result.succ().message("密码错误！");
            }
        }
    }

}

